<template>
	<view class="timer">
		{{seconds}}
	</view>
</template>

<script>
	export default {
		name:"Timer",
		data() {
			return {
				seconds:29,
				timer:null
			};
		},
		created(){
			this.timer = setInterval(()=>{
				this.seconds--;
				if(this.seconds<=0){
					clearInterval(this.timer)
					this.$emit('timeout',false);
				}
			},1000)
		},
		beforeDestroy() {
			clearInterval(this.timer);
		}
	}
</script>

<style lang="scss" scoped>
.timer{
	
}
</style>
